{include file="public/cate" /}
<div class="layui-container">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md8 content detail">
            <div class="fly-panel detail-box">
                <h1>{$ques.title}</h1>
                <div class="fly-detail-info">
                    <span class="layui-badge layui-bg-green fly-detail-column">{$ques.cname}</span>
                    {if condition="$ques.status"}

                    <span class="layui-badge" style="background-color: #5FB878;">已结</span>

                    {else /}
                
                    <span class="layui-badge" style="background-color: #999;">未结</span>

                    {/if}

                    <div class="fly-admin-box" data-id="33354"></div>
                    <span class="fly-list-nums">
                        <a href="#comment">
                            <i class="iconfont" title="回答">&#xe60c;</i>{$ques.reply_num}</a>
                        <i class="iconfont" title="人气">&#xe60b;</i>{$ques.view_num}</span></div>
                <div class="detail-about">
                    <a class="fly-avatar" href="{:url('index/user/center',['uid'=>$ques['uid']])}">
                        <img src="__ROOT__/{$ques.face}" alt="Chris丶"></a>
                    <div class="fly-detail-user">
                        <a href="/u/23778720/" class="fly-link">
                            <cite>{$ques.username}</cite></a>
                        <span>{:Ftime($ques.ctime)}</span></div>
                    <div class="detail-hits" id="LAY_jieAdmin" data-id="33354">
                        <span style="padding-right: 10px; color: #FF7200">悬赏：{$ques.kiss}飞吻</span>

                        {if condition="$ques.coid"}
                        <span class="layui-btn layui-btn-xs jie-admin layui-btn-danger" id="collect" type="collect" data-type="add" qid="{$ques.qid}">取消收藏</span>
                        {else /}
                        <span class="layui-btn layui-btn-xs jie-admin " id="collect" type="collect" data-type="add" qid="{$ques.qid}">收藏</span>
                        {/if}

                    </div>
                </div>
                <div class="detail-body layui-text photos">
                    {if condition="$ques.ext"}
                    <table class="layui-table">
                        <tbody>
                            <tr>
                                <td>版本：{$ques.ext.project} {$ques.ext.version}</td>
                                <td>浏览器：{$ques.ext.browser}</td>
                            </tr>
                        </tbody>
                    </table>
                    {/if}
                    {$ques.content}
                </div>
            </div>
            <div class="fly-panel detail-box" id="flyReply">
                <fieldset class="layui-elem-field layui-field-title" style="text-align: center;">
                    <legend>回帖</legend></fieldset>

                
                
                {if condition="$replys"}

                <ul class="jieda" id="jieda">
                    {volist name="replys" id='replay'}
                    <li data-id="133255">
                        <a name="item-1535960396807"></a>
                        <div class="detail-about detail-about-reply">
                            <a class="fly-avatar" href="/u/10214232/">
                                <img src="__ROOT__/{$replay.face}" alt="BUG开发工程师"></a>
                            <div class="fly-detail-user">
                                <a href="/u/10214232/" class="fly-link">
                                    <cite>{$replay.username}</cite></a>
                            </div>
                            <div class="detail-hits">
                                <span>{:Ftime($replay.ctime)}</span></div>
                        </div>
                        <div class="detail-body layui-text jieda-body photos">{$replay.content}</div>
                        <div class="jieda-reply">
                            <span class="jieda-zan {:$replay.zid ? 'zanok':''}" rid="{$replay.rid}"  type="zan">
                                <i class="iconfont icon-zan"></i>
                                <em>{$replay.zan_num}</em></span>
                            <a href="#comment"><span type="reply" username="{$replay.username}" uid="{$replay.uid}" class="reply">
                                <i class="iconfont icon-svgmoban53"></i>回复</span>
                            </a>
                        </div>
                    </li>
                    {/volist}
                </ul>

                {else /}

                <ul class="jieda" id="jieda"> <li class="fly-none">消灭零回复</li> </ul>

                {/if}
                <div style="text-align: center"></div>
                <a name="comment"></a>
                <div class="layui-form layui-form-pane">
                    <form action="/jie/reply/" method="post">
                        <div class="layui-form-item layui-form-text">
                            <div class="layui-input-block">
                                <textarea id="content" name="content" required placeholder="请输入内容" class="layui-textarea fly-editor" style="height: 150px;"></textarea>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <input type="hidden" name="qid" value="{$ques.qid}">
                            <button class="layui-btn" lay-filter="reply" lay-submit>提交回复</button></div>
                    </form>
                </div>
            </div>
        </div>
        <div class="layui-col-md4">
            {include file="public/weekhot"/}
            <div class="fly-panel">
                <div class="fly-panel-title">心级赞助商
                    <span style="padding: 0 3px;">-</span>
                    <a href="/jie/15697/" class="fly-link fly-joinad    ">我要加入</a></div>
                <div class="fly-panel-main">
                    <a href="http://os.opensns.cn/product/index/download?fly" target="_blank" rel="nofollow" class="fly-zanzhu fly-zanzhu-img" time-limit="2018-10-05 0:0:0">
                        <img src="//cdn.layui.com/upload/2018_8/168_1535714227780_79253.png" alt="opensns"></a>
                    <a href="http://www.larryms.com/cates/5.html" target="_blank" rel="nofollow" class="fly-zanzhu" style="background-color: #64BF98;" time-limit="2018-10-05 0:0:0">60秒极速上手，layui案例排名NO1后台框架</a>
                    <a href="http://www.uileader.com/" target="_blank" rel="nofollow" class="fly-zanzhu" style="background-color: #43BAE9; font-size: 14px;" time-limit="2018-10-20 0:0:0">TouchUI Pro - 一套代码开发App、H5和小程序</a></div>
            </div>
            <div class="fly-panel">
                <div class="fly-panel-title">官方产品</div>
                <div class="fly-panel-main">
                    <a href="http://www.layui.com/admin/?from=fly" target="_blank" class="fly-zanzhu" time-limit="2017.09.25-2099.01.01" style="background-color: #20222A; background-image: linear-gradient(to right,#20222A,#3E4251);">layuiAdmin - layui 官方后台管理模板</a>
                    <a href="http://layim.layui.com/?from=fly" target="_blank" class="fly-zanzhu" time-limit="2017.09.25-2099.01.01" style="background-color: #009688; background-image: linear-gradient(to right,#009688,#5FB878);">LayIM - layui 即时通讯旗舰之作</a></div>
            </div>
            <div class="fly-panel" style="padding: 20px 0; text-align: center;">
                <img src="//cdn.layui.com/upload/2017_8/168_1501894831075_19619.jpg" style="max-width: 100%;" alt="layui">
                <p style="position: relative; color: #666;">微信扫码关注 layui 公众号</p></div>
        </div>
    </div>
</div>
<script>
  //Demo
  layui.use(['form','jquery','layedit'], function(){
    var form = layui.form;
    var $ = layui.jquery;
    var layedit = layui.layedit;


    layedit.set({
      uploadImage: {
        url: '{:url('index/jie/upload')}' //接口url
        ,type: 'post' //默认post
      }
    });

    index = layedit.build('content',{
      height: 120 //设置编辑器高度
    });

    $('.reply').click(function(event) {
        username = $(this).attr('username');
        uid = $(this).attr('uid');

        str = "@ <a href='{:url('index/user/center')}?uid="+uid+"'>"+username+"</a> ";

        layedit.setContent(index,str);

    });

    $('#collect').click(function(event) {
        qid = $(this).attr('qid');

        $.post('{:url('index/jie/collect')}', {qid: qid}, function(res, textStatus, xhr) {

            if(res.code==0){
              layer.msg(res.msg, function(){});
            }else{
                if(res.msg=='收藏成功'){
                    $("#collect").addClass('layui-btn-danger');
                    $("#collect").html("取消收藏");
                }else{
                    $("#collect").removeClass('layui-btn-danger');
                    $("#collect").html("收藏");
                }
            }
        });

    });

    $('.jieda-zan').click(function(event) {
        rid = $(this).attr('rid');
        that = $(this);    
        $.post('{:url('index/jie/zan')}', {rid: rid}, function(res, textStatus, xhr) {

            if(res.code==0){
              layer.msg(res.msg, function(){});
            }else{
                that.addClass('zanok');
                zan_num = parseInt(that.children('em').html());
                zan_num++;
                that.children('em').html(zan_num);
            }
        });

    });


    //监听提交
    form.on('submit(reply)', function(data){
        data.field.content =layedit.getContent(index)
      $.ajax({
        url: '{:url('index/jie/reply')}',
        type: 'POST',
        dataType: 'json',
        data: data.field,
      })
      .done(function(res) {
        if(res.code==0){
          layer.msg(res.msg, function(){
          //关闭后的操作
          });
          $('#code').click();
        }else{
          layer.alert(res.msg, {icon: 6},function(){
              location.href = res.url;
          });
        }
      })
      .fail(function() {
        console.log("error");
      })
      .always(function() {
        console.log("complete");
      });
      
      return false;
    });
  });
    </script>
        